<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<title>一生平安-九宫格页面</title>
<link rel="stylesheet" type="text/css" href="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery.mobile-1.0b1.min.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/lib/mobile/css/jszx-scroll.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/lib/mobile/css/jszx-bar.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/lib/mobile/css/dynamicPic.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/lib/mobile/css/mobile.css" />
	<link type="text/css" href="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery.mobile.datebox.min.css" rel="stylesheet" />
	<script type="text/javascript" src="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery-1.6.4.min.js"></script>
	<script>
	$(document).bind("mobileinit", function(){
		$.mobile.loadingMessage=false;
		$.mobile.selectmenu.prototype.options.nativeMenu = false;
		$.mobile.defaultPageTransition="none";
		$.mobile.listview.prototype.options.filterPlaceholder="";
	});
	</script>
	<script type="text/javascript" src="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery.mobile-1.0b1.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="${ctx}/lib/mobile/js/mobile-common.js" charset="utf-8"></script>
	<script type="text/javascript" src="${ctx}/lib/mobile/js/dynamicPic.js" charset="utf-8"></script>
	<script type="text/javascript" src="${ctx}/lib/mobile/js/mobile.js" charset="utf-8"></script>
	<script type="text/javascript" src="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery.mobile.datebox.js"></script>
	<script type="text/javascript" src="${ctx}/lib/mobile/jquery_mobile_1.0b1/jquery.mobile.datebox.i8n.CHN-S.utf8.js"></script>
</head>
<body>
	<div data-role="page" id="mobile-index-page" class="page-div-style">
		<script>
		$('#mobile-index-page').live('pagebeforeshow',function(){
			//加载等待
			showLoadPage();
			
			//显示头部栏
	 		initHeader($("#mobileIndexHeader"),"menu");
	 		$("#mobileIndexHeader").find("[name='mobileHeaderTitle']").text("健康守护");
	 		
	 		//结束等待
			hideLoadPage();
	 		
			var u = navigator.userAgent;
			if(u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) != null){
				window.mobileSystem = "ios";
			}
			if(u.indexOf('Android') > -1 || u.indexOf('Linux') > -1){
				window.mobileSystem = "android";
			}
		});
		
		$("#mobile-index-page").live("pageshow",function(){
			// 消除原推送绑定
			var userno = window.localStorage.getItem("userno");
			
			if(window.mobileSystem === "ios"){
				var cmd = "delchanleid";
				var str = userno;
		 		window.location.href = "objc://" + cmd + ":/" + str;
			} else if(window.mobileSystem === "android"){
				if(typeof(window.myjs) != "undefined"){
					window.myjs.delchanleid(userno);
				}
			}
			
			var userno_time = window.localStorage.getItem("userno_time");
			
			if("${user}" === ""){
				$("#user_username").hide();
				$("#user_name").hide();
				
				$("#user_login").bind("click",function(){
					gotoLogin();
				});
				$("#user_register").bind("click",function(){
					gotoRegister();
				});
				
				$("#user_login").addClass("div_btn");
				$("#user_register").addClass("div_btn");
				
				var nowDate = new Date();
				if(userno_time != null && nowDate.getTime() - userno_time <= 1000*60*60*24 * 20){
					// 自动登录
					$.ajax({
		                url:"loginByUserNo.html",
		                async: true,
		                type:"POST",
		                data:{"userno":userno},
		                dataType:"json",
		               	success:function(data){	
				            //结束等待
							hideLoadPage();
				            if(data != null){
				            	window.location.href = "${ctx}/mobile/index.html";
				       		} else {
				       			window.location.href = "${ctx}/mobile/login.html";
				       		}
		        		},
		        		error:function(){
			        		//操作 连接超时
			        		connectionFail();
			       		}
		            });
				}
			} else {
				$("#user_login *").hide();
				$("#user_register *").hide();
				$("#user_login").unbind("click",function(){
					gotoLogin();
				});
				$("#user_register").unbind("click",function(){
					gotoRegister();
				});
				
				$("#user_username").show();
				$("#user_name").show();
				$("#user_login").removeClass("div_btn");
				$("#user_register").removeClass("div_btn");
				
				// 注册通知
				window.localStorage.setItem("userno","${user.userno}");
				window.localStorage.setItem("userno_time",new Date().getTime());
				
				if(window.mobileSystem === "ios"){
					var cmd = "setchanleid";
					var str = "${user.userno}";
			 		window.location.href = "objc://" + cmd + ":/" + str;
				} else if(window.mobileSystem === "android"){
					if(typeof(window.myjs) != "undefined"){
						window.myjs.setchanleid("${user.userno}");
					}
				}
			}
			$("#mobileIndexScroller").css("height",window.innerHeight - $("#mobileIndexHeader").height() - $("#mobileIndexPageFooter").height() + 1 + "px");
		});
		
		//健康排程
		function healthSchedule(){
			window.location.href = "${ctx}/mobile/healthSchedule/toSchedulePage.html";
		}
		
		//登录
		function gotoLogin(){
			window.location.href = "${ctx}/mobile/login.html";
		}
		
		//注册
		function gotoRegister(){
			window.location.href = "${ctx}/mobile/register.html";
		}
		
		//健康叮咛
		function healthWarn(){
			menuMORE.showMsgBox();
		}
		
		//用药提醒
		function drugWarn(){
			menuMORE.showMsgBox();
		}
		
		// 个人中心
		function userCenter(){
			window.location.href = "${ctx}/mobile/userCenter.html";
		}
		
		// 健康日记
		function indexJKRJ(){
			window.location.href = "${ctx}/mobile/indexJKRJ.html";
		}
		
		// 健康管理
		function indexJKGL(){
			window.location.href = "${ctx}/mobile/indexJKGL.html";
		}
		
		// 健康课堂
		function indexJKKT(){
			window.location.href = "${ctx}/mobile/indexJKKT.html";
		}
		
		// 母婴专区
		function indexMYZQ(){
			window.location.href = "${ctx}/mobile/indexMYZQ.html";
		}
		
		// 健康商城
		function indexJKSC(){
			window.location.href = "${ctx}/mobile/indexJKSC.html";
		}
		
		// 活动公告
		function indexHDGG(){
			window.location.href = "${ctx}/mobile/yspaInterface/hactivityList.html";
		}
		
		// 健康视讯
		function indexJKSX(){
			if(window.mobileSystem === "ios"){
				var cmd = "tel";
				var str = "0538-5010666";
		 		window.location.href = "objc://" + cmd + ":/" + str;
			}else if(window.mobileSystem === "android"){
				if(typeof(window.myjs) != "undefined"){
					window.myjs.tel("0538-5010666");
				}
			}
		}
		
		</script>
		<div style="position:absolute;width:100%;height:100%;top:0;display:none;z-index:100;" id="loginWait">
			<div style="position:absolute;height:100%;width:100%;top:0;">
				<div style="top:40%;height:90px;border-radius:8px;-webkit-box-shadow:1px 1px 1px #ccc;
					background:#ffffff;text-align:center;opacity:0.8;position: absolute;
					z-index: 100;left: 50%;width: 200px;margin-left: -130px;margin-top: -35px;padding: 10px 30px;">
					<img id="load_img" src="${ctx}/lib/mobile/image/load.gif" style="position:relative;">
					<p id="load_content" style="position:relative;">加载中...</p>
				</div>
			</div>
		</div>
		<div id="aboutMobile_opacity" class="menu_opacity">
			<div class="menu_opacity_black">
			</div>
			<div class="menu_opacity_showBox" id="index_showBox" onclick="index.hideMsgBox()">
				<div class="msgbox alert-box-anim">
					<div class="tips">健康提醒</div>
					<div>
						<div class="ui-grid-a ui-grid-box-a">
							<div class="ui-block-a"><div class="ui-bar ui-bar-c" onclick="healthSchedule();">
								<img src="${ctx}/lib/mobile/image/health-schedule.png">
								<div>健康排程</div>
							</div></div>
							<div class="ui-block-b"><div class="ui-bar ui-bar-c ">
								<img src="${ctx}/lib/mobile/image/health-warn.png">
								<div>健康叮咛</div>
							</div></div>
							<div class="ui-block-a"><div class="ui-bar ui-bar-c ">
								<img src="${ctx}/lib/mobile/image/drug-warn.png">
								<div>用药提醒</div>
							</div></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div align="center" data-role="header" data-theme="b"  data-position="" id="mobileIndexHeader">
		</div>
		<div data-role="" id="mobileIndexWrapper" style="padding:0;margin: 0px;" class="jszx-wrapper">
			<div id="mobileIndexScroller" class="jszx-scroller" style="    border-bottom: 1px solid red;">
				<div align="center" style="height:30%;background: url(${ctx}/lib/mobile/image/index_bg.jpg) no-repeat;background-size: cover;">
					<table style="width: 100%;top: 8%;position: relative;">
						<tr>
							<td colspan="2" align="center"><img style="width:20%;margin-bottom: 10px;" src="${ctx}/lib/mobile/image/login-img.png"></td>
						</tr>
						<tr>
							<td align="right" style="width:50%">
								<div id="user_login" class="div_text" align="center" style="right: 10px;">
								    <div id="user_username">${user.userid}</div>
								    <img src="${ctx}/lib/mobile/image/login_btn.png">
									<div>登录</div>
								</div>
    						</td>
							<td align="left" style="width:50%">
								<div id="user_register" class="div_text" align="center"  style="left: 10px;">
								    <div id="user_name">${user.name}</div>
								    <img src="${ctx}/lib/mobile/image/login_btn.png">
									<div>注册</div>
								</div>
    						</td>
						</tr>
					</table>
				</div>
				<div class="ui-grid-b" style="height:70%;">
					<div class="ui-block-a"><div class="ui-bar ui-bar-c " onclick="indexJKRJ();">
						<img src="${ctx}/lib/mobile/image/jiankangriji.png">
						<div>健康日记</div>
					</div></div>
					<div class="ui-block-b"><div class="ui-bar ui-bar-c " onclick="indexJKGL();">
						<img src="${ctx}/lib/mobile/image/jiankangguanli.png">
						<div>健康管理</div>
					</div></div>
					<div class="ui-block-c"><div class="ui-bar ui-bar-c " onclick="indexJKKT();">
						<img src="${ctx}/lib/mobile/image/jiankangketang.png">
						<div>健康课堂</div>
					</div></div>
					
					<div class="ui-block-a"><div class="ui-bar ui-bar-c " onclick="indexMYZQ();">
						<img src="${ctx}/lib/mobile/image/muyingzhuanqu.png">
						<div>母婴专区</div>
					</div></div>
					<div class="ui-block-b"><div class="ui-bar ui-bar-c " onclick="indexJKSX();">
						<img src="${ctx}/lib/mobile/image/jiankangshixun.png">
						<div>健康视讯</div>
					</div></div>
					<div class="ui-block-c"><div class="ui-bar ui-bar-c ">
						<img src="${ctx}/lib/mobile/image/huiyuanzhuanshu.png">
						<div>会员专属</div>
					</div></div>
					
					<div class="ui-block-a"><div class="ui-bar ui-bar-c " onclick="indexHDGG();">
						<img src="${ctx}/lib/mobile/image/huodonggonggao.png">
						<div>活动公告</div>
					</div></div>
					<div class="ui-block-b"><div class="ui-bar ui-bar-c " onclick="indexJKSC();">
						<img src="${ctx}/lib/mobile/image/jiankangshangcheng.png">
						<div>健康商城</div>
					</div></div>
					<div class="ui-block-c"><div class="ui-bar ui-bar-c " onclick="userCenter();">
						<img src="${ctx}/lib/mobile/image/gerenzhongxin.png">
						<div>个人中心</div>
					</div></div>
				</div>
			</div>
		</div>
		<div data-role="footer" data-theme="b" data-position="" id="mobileIndexPageFooter" class="footer_div_style"
			align="center">
			<div style="font-family: 黑体;height: 25px;line-height: 25px;font-size: 80%;font-weight: normal;">一生平安健康管理中心</div>
			<div style="font-family: 黑体;height: 25px; font-size: 80%;font-weight: normal;">健康热线：0538-5010666</div>
		</div>
	</div>
</body>
</html>